@extends('layouts.admin')

@section('style')
    <style>
        #page li {
            display: inline-block;
        }

        #page .active span {
            background-color: #009688;
            color: #fff;
            border: 0px;
            height: 30px;
            border-radius: 2px;
        }

        #page .disabled span {
            color: #ccc;
        }
    </style>
@endsection

@section('content')

    <input class="layui-btn layui-btn-normal" type="file" name="file" id="ID-upload-demo-form-files">

    {{--<div class="layui-input-inline" style="padding-left:10px; width: 300px;">
        <input type="tel" name="keywords" id="keywords" lay-verify="required" autocomplete="off" placeholder="手机号/联盟名称" class="layui-input">
    </div>
    <button class="layui-btn search-btn-union" style="padding-left:20px">搜索</button>--}}
    <table class="layui-table">
        <colgroup>
            <col width="50">
        </colgroup>
        <thead>
        <tr>
            <th width="25%">文件名</th>
            <th>实收金额</th>
            <th>应收(货款)金额</th>
            <th>利润</th>
        </tr>
        </thead>
        <tbody class="water-pipe">
            <!-- <tr>
                <td class="originalName"></td>
                <td class="actualTotalPrice">0</td>
                <td class="receivableTotalPrice">0</td>
                <td class="profit">0</td>
            </tr> -->
        </tbody>
    </table>

    <div id="page" class="layui-box layui-laypage layui-laypage-default">{{ $reportLists->appends(['keywords' => $keywords])->links() }}</div>
@endsection

@section('script')

    <script>
        $('.search-btn-union').on('click',function(){
            var keywords = $('#keywords').val();
            var url = '/admin/report/index?keywords='+keywords;
            window.location.href = url; //当前窗口打开
        });
        var keywords = $('#keywords').val();

        layui.use(['layer','upload'], function () {
            var layer = layui.layer;
            var upload = layui.upload;
            // 渲染
            upload.render({
                elem: '#ID-upload-demo-form-files',
                url: "{{ route('admin.waterPipe.upload') }}", // 此处配置你自己的上传接口即可
                accept:'file',
                headers:{'X-CSRF-TOKEN': '{{ csrf_token() }}'},
                done: function(data){
                    console.log(data)
                    if (data.code === 0) {
                        // $('.originalName').text(data.data.originalName);
                        // $('.actualTotalPrice').text(data.data.actualTotalPrice);
                        // $('.receivableTotalPrice').text(data.data.receivableTotalPrice);
                        // $('.profit').text(data.data.profit);
                        $('.water-pipe').append('<tr><td>'+data.data.originalName+'</td><td>'+data.data.actualTotalPrice+'</td><td>'+data.data.receivableTotalPrice+'</td><td>'+data.data.profit+'</td></tr>');

                    } else {
                        layer.msg(data.msg, {
                            offset: '15px'
                            , icon: 2
                            , time: 2000
                        });
                    }
                }
            });
        });
    </script>

@endsection